/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.h;

import android.content.Context;
import android.text.TextUtils;
import com.qihoo.gamecenter.sdk.common.i.k;
import com.qihoo.gamecenter.sdk.common.i.s;
import java.net.URLEncoder;
import java.util.ArrayList;
import org.apache.http.NameValuePair;

public class h {
    public static String a(String paramString, boolean paramBoolean) {
        e.a("Plugin.LoginStatUtils", new Object[] { "extractApiFromUrl Entry! url = ", paramString });
        String str1 = paramString;
        if (TextUtils.isEmpty(paramString)) {
            str1 = (paramBoolean) ? "zhushouservicelogin" : "";
        }
        else if (paramString.startsWith("https://passport.360.cn/api.php?")) {
            String str2 = a(paramString);
            if (!(TextUtils.isEmpty(str2))) {
                str1 = "http://login.360.cn/intf.php?method=" + str2;
                if (paramBoolean)
                    str1 = str1 + "&type=zhushouservicelogin";
            }
        }
        else {
            int i = paramString.indexOf("?");
            if (i > 0)
                str1 = paramString.substring(0, i);
        }
        e.a("Plugin.LoginStatUtils", new Object[] { "extract res = ", str1 });
        try {
            str1 = URLEncoder.encode(str1, "UTF-8");
        } catch (Exception localException) {}
        return str1;
    }

    private static String a(String paramString) {
        String str1 = paramString.substring("https://passport.360.cn/api.php?".length());
        if (!(TextUtils.isEmpty(str1))) {
            String str2 = a(str1, "parad");
            if (!(TextUtils.isEmpty(str2))) {
                String str3 = com.qihoo.gamecenter.sdk.common.i.f.b(str2);
                String str4 = com.qihoo.gamecenter.sdk.common.i.f.d(str3, com.qihoo.gamecenter.sdk.common.e.a.a());
                String str5 = a(str4, "method");
                return str5;
            }
        }
        return "";
    }

    private static String a(String paramString1, String paramString2) {
        String[] arrayOfString1 = paramString1.split("&");
        for (String str : arrayOfString1) {
            if (TextUtils.isEmpty(str))
                continue;
            String[] arrayOfString3 = str.split("=");
            if (null == arrayOfString3)
                continue;
            if (arrayOfString3.length < 2)
                continue;
            if (arrayOfString3[0].equals(paramString2))
                return arrayOfString3[1];
        }
        return "";
    }

    public static void a(Context paramContext, String paramString1, String paramString2, String paramString3,
            boolean paramBoolean) {
        e.a("Plugin.LoginStatUtils", new Object[] { "sendApiErrorStat entry! errcode = ", paramString1, " url = ",
                paramString2, " content = ", paramString3 });
        if (TextUtils.isEmpty(paramString2))
            return;
        new Thread(new Runnable(paramContext, paramString2, paramBoolean, paramString1, paramString3) {
            public void run() {
                String str1 = f.e();
                String str2 = s.r(this.a);
                String str3 = k.a(f.g(this.a));
                long l = System.currentTimeMillis();
                String str4 = h.a(this.b, this.c);
                StringBuilder localStringBuilder = new StringBuilder();
                localStringBuilder.append("http://gc.mobilem.360.cn/gamecenter/failedreport?");
                localStringBuilder.append("sdkver=" + str1);
                localStringBuilder.append("&");
                localStringBuilder.append("appid=" + str2);
                localStringBuilder.append("&");
                localStringBuilder.append("errcode=" + this.d);
                localStringBuilder.append("&");
                localStringBuilder.append("api=" + str4);
                localStringBuilder.append("&");
                localStringBuilder.append("mid=" + str3);
                localStringBuilder.append("&");
                localStringBuilder.append("t=" + String.valueOf(l));
                String str5 = localStringBuilder.toString();
                e.a("Plugin.LoginStatUtils", new Object[] { "url = ", str5 });
                String str6 = this.e;
                if (null == str6)
                    str6 = "";
                ArrayList localArrayList = new ArrayList();
                localArrayList.add(new h.a("content", str6));
                String str7 = com.qihoo.gamecenter.sdk.login.plugin.d.a.a(this.a, localArrayList, str5);
                e.a("Plugin.LoginStatUtils", new Object[] { "res = ", str7 });
            }
        }).start();
    }

    public static void a(Context paramContext, long paramLong) {
        e.a("Plugin.LoginStatUtils", new Object[] { "saveLoginTimeCost4Stat cost = ", Long.valueOf(paramLong) });
        g.a(paramContext, "last_login_time_cost", paramLong);
    }

    public static long a(Context paramContext) {
        long l = g.g(paramContext, "last_login_time_cost");
        g.a(paramContext, "last_login_time_cost", 0L);
        return l;
    }

    public static void a(Context paramContext, long paramLong, String paramString) {
        e.a("Plugin.LoginStatUtils", new Object[] { "saveRegisterTimeCost4Stat cost = ", Long.valueOf(paramLong),
                " type = ", paramString });
        g.a(paramContext, "last_reg_time_cost", paramLong);
        g.b(paramContext, "last_reg_type", paramString);
    }

    public static long b(Context paramContext) {
        long l = g.g(paramContext, "last_reg_time_cost");
        g.a(paramContext, "last_reg_time_cost", 0L);
        return l;
    }

    public static String c(Context paramContext) {
        String str = g.h(paramContext, "last_reg_type");
        g.b(paramContext, "last_reg_type", "");
        return str;
    }

    private static class a implements NameValuePair {
        private String a;
        private String b;

        a(String paramString1, String paramString2) {
            this.a = paramString1;
            this.b = paramString2;
        }

        public String getName() {
            return this.a;
        }

        public String getValue() {
            return this.b;
        }
    }
}